<template>
  <view class="system-menu">
    <su-menu-group :title="lv1.meta.title" v-for="(lv1,lv1Index) in menuList" :key="lv1Index" v-if="!lv1.hidden">
      <su-menu-list :msgNums="msgNums" :list="lv1.children || []"></su-menu-list>
    </su-menu-group>
  </view>
</template>

<script>
  /**
   * @description 用户权限内菜单
   * @date 2022-03-12
   * @version v1.0.1
   * @author gf
   */
  import {
    getRouters
  } from '@/common/api.js'
  import {mapState} from 'vuex'
  export default {
    name: 'system-menu',
    data() {
      return {
        msgNums:{
          "todo":12,
          "purchase-list":2,
          "useandreturn":6,
          "maintainplan":3,
          "assetcheck":4,
          "flowable":101
        },
        menuList:[]
      }
    },
    computed:{
      ...mapState(['token'])
    },
    mounted() {
      this.getMenus()
    },
    watch: {
      token(newVal) {
        this.getMenus()
      }
    },
    methods: {
      // 首页导航点击
      getMenus() {
        getRouters().then(res=>{
          this.menuList = res.data || []
        })
      }
    }
  }
</script>

<style lang="scss">
  .system-menu {}
</style>
